<!doctype html>

<title>CodeMirror: Lazy Mode Loading Demo</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../doc/docs.css">

<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../addon/mode/loadmode.js"></script>
<script src="../mode/meta.js"></script>
<style type="text/css">
      .CodeMirror {
    /* border-top: 1px solid black; */
    /* border-bottom: 1px solid black; */
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
}




</style>

<article>
  <p style="color: gray">Current mode: <span id="modeinfo">text/plain</span></p>
  <form><textarea id="code" name="code">
</textarea></form>
  <p>Filename, mime, or mode name: <input type=text value=foo.js id=mode>
    <button type=button onclick="change()">change mode</button>
  </p>

  <script type="text/javascript">
CodeMirror.modeURL = "../mode/%N/%N.js";
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  lineNumbers: true,
  readOnly: 'nocursor'
});
function setLanguage(val) {
  var m, mode, spec;
  if (m = /.+\.([^.]+)$/.exec(val)) {
    var info = CodeMirror.findModeByExtension(m[1]);
    if (info) {
      mode = info.mode;
      spec = info.mime;
    }
  } else if (/\//.test(val)) {
    var info = CodeMirror.findModeByMIME(val);
    if (info) {
      mode = info.mode;
      spec = val;
    }
  } else {
    mode = spec = val;
  }
  if (mode) {
    editor.setOption("mode", spec);
    CodeMirror.autoLoadMode(editor, mode);
    document.getElementById("modeinfo").textContent = spec;
    var v = Android.getSource();
    editor.setValue(v);
  } else {
    alert("Could not find a mode corresponding to " + val);
  }

}
function setContent(cc) {
  var v = Android.getSource();
  editor.setValue(v);
}


function f1(content) {
  alert(content);
  return content;
}




  </script>
</article>
